# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[self._vol = 50
self._mute = 0
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d656c>}
nname: 0
n 0(None)[return (self._vol, self._vol)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d65ec>}
nname: 0
n 0(None)[self._vol = val
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d652c>}
nname: 0
n 0(None)[return (self._mute, self._mute)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d64cc>}
nname: 0
n 0(None)[self._mute = val
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d64ec>}
nname: 6
n 6(None)[__doc__ = ' only used on x86 '
def __init__(self, *args, **args):
	self._vol = 50
	self._mute = 0

def getvolume(self):
	return (self._vol, self._vol)

def setvolume(self, val):
	self._vol = val

def getmute(self):
	return (self._mute, self._mute)

def setmute(self, val):
	self._mute = val

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76c1f4c>}
nname: 106
n 106(None)[events_watch(self.handle)
self.window = SoundLevelWindow(_('Sound level'))
self.mute_window = MuteWindow(_('Mute'))
self._hide_task = Task(self.window.hide)
self._hide_mute_task = Task(self.mute_window.hide)
self._save_task = Task(user_config.save)
self.soft_mute_flag = 0
self.soft_mute_prev_vol = 0
self._fill_limiters()
self._gain = False
self._vol_id = user_config['sound']['volume']
self.set_volume(self._vol_id)
self.set_mute(user_config['sound']['mute'])
self.set_hdmi_mute(user_config['connections']['hdmi_sound'])
self._notification()
]:
	i: 63(), 92()
	o: 

nname: 92
n 92(None)[self.add_control(control)
]:
	i: 0(f)
	o: 106()

nname: 63
n 63(None)[self._mixers['Fake'] = FakeMixer()
self._def_control = 'Fake'
]:
	i: 0(t)
	o: 106()

nname: 0
n 0(architecture == 'pc')[self._mixers = dict()
self._limiters = dict()
self._def_control = control
self._def_id = id
self._def_card = card
]:
	i: 
	o: 63(t), 92(f)

nname: 0
n 0(None)[self._mixers = dict()
self._limiters = dict()
self._def_control = control
self._def_id = id
self._def_card = card
if architecture == 'pc':
	self._mixers['Fake'] = FakeMixer()
	self._def_control = 'Fake'
else:
	self.add_control(control)
events_watch(self.handle)
self.window = SoundLevelWindow(_('Sound level'))
self.mute_window = MuteWindow(_('Mute'))
self._hide_task = Task(self.window.hide)
self._hide_mute_task = Task(self.mute_window.hide)
self._save_task = Task(user_config.save)
self.soft_mute_flag = 0
self.soft_mute_prev_vol = 0
self._fill_limiters()
self._gain = False
self._vol_id = user_config['sound']['volume']
self.set_volume(self._vol_id)
self.set_mute(user_config['sound']['mute'])
self.set_hdmi_mute(user_config['connections']['hdmi_sound'])
self._notification()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d6bac>}
nname: 45
n 45(None)[]:
	i: 15(), 44()
	o: 

nname: 44
n 44(None)[]:
	i: 0(f)
	o: 45()

nname: 15
n 15(None)[getattr(self, event.name.lower())()
]:
	i: 0(t)
	o: 45()

nname: 0
n 0(event.name in ('VOLUME_DOWN', 'VOLUME_UP', 'MUTE'))[]:
	i: 
	o: 15(t), 44(f)

nname: 0
n 0(None)[if event.name in ('VOLUME_DOWN', 'VOLUME_UP', 'MUTE'):
	getattr(self, event.name.lower())()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0a8c>}
nname: 88
n 88(None)[]:
	i: 3(), 42(), 86(AE)
	o: 

nname: 86
n 86(None)[]:
	i: 32(f)
	o: 88(AE)

nname: 42
n 42(None)[gain = Mixer('Gain Override', self._def_id, self._def_card)
gain.setmute(0)
]:
	i: 32(t)
	o: 88()

nname: 32
n 32(<dummy_ex3> EXC_MATCH ALSAAudioError)[]:
	i: 0(except)
	o: 42(t), 86(f)

nname: 3
n 3(None)[gain = Mixer('Gain Override')
gain.setmute(0)
]:
	i: 0(try)
	o: 88()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 32(except)

nname: 32
n 32(None)[except ALSAAudioError:
	gain = Mixer('Gain Override', self._def_id, self._def_card)
	gain.setmute(0)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	gain = Mixer('Gain Override')
	gain.setmute(0)
]:
	i: 
	o: 32()

nname: 0
n 0(None)[try:
	gain = Mixer('Gain Override')
	gain.setmute(0)
except ALSAAudioError:
	gain = Mixer('Gain Override', self._def_id, self._def_card)
	gain.setmute(0)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0aac>}
nname: 93
n 93(None)[]:
	i: 0(AL), 92()
	o: 

nname: 92
n 92(None)[]:
	i: 3(AF), 89()
	o: 93()

nname: 89
n 89(None)[]:
	i: 87(AE)
	o: 92()

nname: 87
n 87(None)[]:
	i: 39(f), 49()
	o: 89(AE)

nname: 49
n 49(None)[self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
continue
]:
	i: 39(t)
	o: 87()

nname: 39
n 39(<dummy_ex3> EXC_MATCH ALSAAudioError)[]:
	i: 10(except), 16()
	o: 49(t), 87(f)

nname: 16
n 16(None)[self._limiters[limiter] = Mixer(limiter)
continue
]:
	i: 10(try)
	o: 39()

nname: 10
n 10(None)[for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
]:
	i: 3(for)
	o: 16(try), 39(except)

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 10(for), 92(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 93(AL)

nname: 93
n 93(None)[]:
	i: 0(AL), 3(AF), 39(AE)
	o: 

nname: 39
n 39(None)[except ALSAAudioError:
	self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
	continue
]:
	i: 10()
	o: 93(AE)

nname: 10
n 10(None)[for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
try:
	self._limiters[limiter] = Mixer(limiter)
	continue
]:
	i: 3(for)
	o: 39()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 10(for), 93(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 93(AL)

nname: 93
n 93(None)[]:
	i: 0(AL), 3(AF), 10(AE)
	o: 

nname: 10
n 10(None)[for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
try:
	self._limiters[limiter] = Mixer(limiter)
	continue
except ALSAAudioError:
	self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
	continue
]:
	i: 3(for)
	o: 93(AE)

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 10(for), 93(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 93(AL)

nname: 93
n 93(None)[]:
	i: 10(AE)
	o: 

nname: 10
n 10(None)[for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
	try:
		self._limiters[limiter] = Mixer(limiter)
		continue
	except ALSAAudioError:
		self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
		continue
]:
	i: 0(for)
	o: 93(AE)

nname: 0
n 0(None)[]:
	i: 
	o: 10(for)

nname: 93
n 93(None)[]:
	i: 0(AE)
	o: 

nname: 0
n 0(None)[for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
	try:
		self._limiters[limiter] = Mixer(limiter)
		continue
	except ALSAAudioError:
		self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
		continue
]:
	i: 
	o: 93(AE)

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d012c>, 93: <unpyclib.structure.node instance at 0xb76d0c8c>}
nname: 137
n 137(None)[]:
	i: 103(), 120()
	o: 

nname: 120
n 120(None)[self._hide_mute_task.start(0)
]:
	i: 71(f)
	o: 137()

nname: 103
n 103(None)[self.mute_window.show()
]:
	i: 71(t)
	o: 137()

nname: 71
n 71(self.get_mute())[self._hide_task.start(HMI_BASE['volumewindow_duration'])
]:
	i: 53(), 70()
	o: 103(t), 120(f)

nname: 70
n 70(None)[]:
	i: 0(t)
	o: 71()

nname: 53
n 53(None)[self.window.show()
]:
	i: 0(f)
	o: 71()

nname: 0
n 0(self._hide_task.running)[self.window.mute = self.get_mute()
self.window.progress = volume_progress_dict[self._vol_id]['progress']
]:
	i: 
	o: 53(f), 70(t)

nname: 137
n 137(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[self.window.mute = self.get_mute()
self.window.progress = volume_progress_dict[self._vol_id]['progress']
if not self._hide_task.running:
	self.window.show()
self._hide_task.start(HMI_BASE['volumewindow_duration'])
if self.get_mute():
	self.mute_window.show()
else:
	self._hide_mute_task.start(0)
]:
	i: 
	o: 137()

nname: 0
n 0(None)[self.window.mute = self.get_mute()
self.window.progress = volume_progress_dict[self._vol_id]['progress']
if not self._hide_task.running:
	self.window.show()
self._hide_task.start(HMI_BASE['volumewindow_duration'])
if self.get_mute():
	self.mute_window.show()
else:
	self._hide_mute_task.start(0)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0c4c>}
nname: 76
n 76(None)[]:
	i: 3(), 36(), 74(AE)
	o: 

nname: 74
n 74(None)[]:
	i: 26(f)
	o: 76(AE)

nname: 36
n 36(None)[self._mixers[control] = Mixer(control, self._def_id, self._def_card)
]:
	i: 26(t)
	o: 76()

nname: 26
n 26(<dummy_ex3> EXC_MATCH ALSAAudioError)[]:
	i: 0(except)
	o: 36(t), 74(f)

nname: 3
n 3(None)[self._mixers[control] = Mixer(control)
]:
	i: 0(try)
	o: 76()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 26(except)

nname: 26
n 26(None)[except ALSAAudioError:
	self._mixers[control] = Mixer(control, self._def_id, self._def_card)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	self._mixers[control] = Mixer(control)
]:
	i: 
	o: 26()

nname: 0
n 0(None)[try:
	self._mixers[control] = Mixer(control)
except ALSAAudioError:
	self._mixers[control] = Mixer(control, self._def_id, self._def_card)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0b0c>}
nname: 61
n 61(None)[]:
	i: 0(AL), 60()
	o: 

nname: 60
n 60(None)[]:
	i: 19(AF), 35()
	o: 61()

nname: 35
n 35(None)[for name, mix in self._limiters.iteritems():
mix.setmute(val)
]:
	i: 19(for)
	o: 60()

nname: 19
n 19(None)[]:
	i: 0(loop)
	o: 35(for), 60(AF)

nname: 0
n 0(None)[log.debug('switch limiters to: %s', val)
]:
	i: 
	o: 19(loop), 61(AL)

nname: 61
n 61(None)[]:
	i: 35()
	o: 

nname: 35
n 35(None)[for name, mix in self._limiters.iteritems():
	mix.setmute(val)
]:
	i: 0(for)
	o: 61()

nname: 0
n 0(None)[log.debug('switch limiters to: %s', val)
]:
	i: 
	o: 35(for)

nname: 61
n 61(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[log.debug('switch limiters to: %s', val)
for name, mix in self._limiters.iteritems():
	mix.setmute(val)
]:
	i: 
	o: 61()

nname: 0
n 0(None)[log.debug('switch limiters to: %s', val)
for name, mix in self._limiters.iteritems():
	mix.setmute(val)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0d8c>}
nname: 94
n 94(None)[return volume
]:
	i: 65(), 79(), 92(AE)
	o: 

nname: 92
n 92(None)[]:
	i: 69(f)
	o: 94(AE)

nname: 79
n 79(None)[volume = 0
]:
	i: 69(t)
	o: 94()

nname: 69
n 69(<dummy_ex3> EXC_MATCH ALSAAudioError)[]:
	i: 13(except)
	o: 79(t), 92(f)

nname: 65
n 65(None)[]:
	i: 51(), 64()
	o: 94()

nname: 64
n 64(None)[]:
	i: 19(f)
	o: 65()

nname: 51
n 51(None)[volume = self.soft_mute_prev_vol
]:
	i: 19(t)
	o: 65()

nname: 19
n 19(self.soft_mute_flag)[volume = self._mixers[ctrl].getvolume()[0]
]:
	i: 13(try)
	o: 51(t), 64(f)

nname: 13
n 13(None)[ctrl = control
]:
	i: 0(t), 6()
	o: 19(try), 69(except)

nname: 6
n 6(None)[]:
	i: 0(f)
	o: 13()

nname: 0
n 0(control)[]:
	i: 
	o: 6(f), 13(t)

nname: 94
n 94(None)[return volume
]:
	i: 69(), 19()
	o: 

nname: 69
n 69(None)[except ALSAAudioError:
	volume = 0
]:
	i: 19()
	o: 94()

nname: 94
n 94(None)[return volume
]:
	i: 69(), 19()
	o: 

nname: 19
n 19(None)[try:
	volume = self._mixers[ctrl].getvolume()[0]
	if self.soft_mute_flag:
		volume = self.soft_mute_prev_vol
]:
	i: 0(try)
	o: 94(), 69()

nname: 0
n 0(None)[if not control:
	pass
ctrl = control
]:
	i: 
	o: 19(try)

nname: 94
n 94(None)[return volume
]:
	i: 69(), 0()
	o: 

nname: 69
n 69(None)[except ALSAAudioError:
	volume = 0
]:
	i: 0()
	o: 94()

nname: 94
n 94(None)[return volume
]:
	i: 69(), 0()
	o: 

nname: 0
n 0(None)[if not control:
	pass
ctrl = control
try:
	volume = self._mixers[ctrl].getvolume()[0]
	if self.soft_mute_flag:
		volume = self.soft_mute_prev_vol
]:
	i: 
	o: 94(), 69()

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0e4c>, 69: <unpyclib.structure.node instance at 0xb76d09ac>, 94: <unpyclib.structure.node instance at 0xb76d6d0c>}
nname: 289
n 289(None)[]:
	i: 242(), 288()
	o: 

nname: 288
n 288(None)[]:
	i: 236(t)
	o: 289()

nname: 242
n 242(None)[self._vol_id = vol_id
user_config['sound']['volume'] = self._vol_id
self._save_task.start(1)
]:
	i: 236(f)
	o: 289()

nname: 236
n 236(dummy)[]:
	i: 166(), 190(AL), 235()
	o: 242(f), 288(t)

nname: 235
n 235(None)[]:
	i: 194(AF), 210()
	o: 236()

nname: 210
n 210(None)[for name, mix in self._mixers.iteritems():
mix.setvolume(volume)
]:
	i: 194(for)
	o: 235()

nname: 194
n 194(None)[]:
	i: 190(loop)
	o: 210(for), 235(AF)

nname: 190
n 190(None)[]:
	i: 160(f)
	o: 194(loop), 236(AL)

nname: 166
n 166(None)[self._mixers[control].setvolume(volume)
]:
	i: 160(t)
	o: 236()

nname: 160
n 160(control)[]:
	i: 85(), 124()
	o: 166(t), 190(f)

nname: 124
n 124(None)[self._gain = False
log.debug('gain OFF')
self.switch_limiters(1)
]:
	i: 0(f)
	o: 160()

nname: 85
n 85(None)[self._gain = True
log.debug('gain ON')
self.switch_limiters(0)
]:
	i: 0(t)
	o: 160()

nname: 0
n 0(volume >= 12.5)[vol_id = min(vol_id, len(volume_progress_dict) - 1)
vol_id = max(vol_id, 0)
volume = volume_progress_dict[vol_id]['vol']
log.debug('vol_id:%s volume=%s', vol_id, volume)
]:
	i: 
	o: 85(t), 124(f)

nname: 236
n 236(None)[if not dummy:
	self._vol_id = vol_id
	user_config['sound']['volume'] = self._vol_id
	self._save_task.start(1)
]:
	i: 166(), 210()
	o: 

nname: 210
n 210(None)[for name, mix in self._mixers.iteritems():
	mix.setvolume(volume)
]:
	i: 190(for)
	o: 236()

nname: 190
n 190(None)[]:
	i: 0(f)
	o: 210(for)

nname: 166
n 166(None)[self._mixers[control].setvolume(volume)
]:
	i: 0(t)
	o: 236()

nname: 0
n 0(control)[vol_id = min(vol_id, len(volume_progress_dict) - 1)
vol_id = max(vol_id, 0)
volume = volume_progress_dict[vol_id]['vol']
log.debug('vol_id:%s volume=%s', vol_id, volume)
if volume >= 12.5:
	self._gain = True
	log.debug('gain ON')
	self.switch_limiters(0)
else:
	self._gain = False
	log.debug('gain OFF')
	self.switch_limiters(1)
]:
	i: 
	o: 166(t), 190(f)

nname: 236
n 236(None)[if not dummy:
	self._vol_id = vol_id
	user_config['sound']['volume'] = self._vol_id
	self._save_task.start(1)
]:
	i: 166(), 190()
	o: 

nname: 190
n 190(None)[for name, mix in self._mixers.iteritems():
	mix.setvolume(volume)
]:
	i: 0(f)
	o: 236()

nname: 166
n 166(None)[self._mixers[control].setvolume(volume)
]:
	i: 0(t)
	o: 236()

nname: 0
n 0(control)[vol_id = min(vol_id, len(volume_progress_dict) - 1)
vol_id = max(vol_id, 0)
volume = volume_progress_dict[vol_id]['vol']
log.debug('vol_id:%s volume=%s', vol_id, volume)
if volume >= 12.5:
	self._gain = True
	log.debug('gain ON')
	self.switch_limiters(0)
else:
	self._gain = False
	log.debug('gain OFF')
	self.switch_limiters(1)
]:
	i: 
	o: 166(t), 190(f)

nname: 0
n 0(None)[vol_id = min(vol_id, len(volume_progress_dict) - 1)
vol_id = max(vol_id, 0)
volume = volume_progress_dict[vol_id]['vol']
log.debug('vol_id:%s volume=%s', vol_id, volume)
if volume >= 12.5:
	self._gain = True
	log.debug('gain ON')
	self.switch_limiters(0)
else:
	self._gain = False
	log.debug('gain OFF')
	self.switch_limiters(1)
if control:
	self._mixers[control].setvolume(volume)
else:
	for name, mix in self._mixers.iteritems():
		mix.setvolume(volume)
if not dummy:
	self._vol_id = vol_id
	user_config['sound']['volume'] = self._vol_id
	self._save_task.start(1)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76cc40c>}
nname: 74
n 74(None)[return mute
]:
	i: 19(), 56(), 72(AE)
	o: 

nname: 72
n 72(None)[]:
	i: 46(f)
	o: 74(AE)

nname: 56
n 56(None)[mute = self.soft_mute_flag
]:
	i: 46(t)
	o: 74()

nname: 46
n 46(<dummy_ex3> EXC_MATCH ALSAAudioError)[]:
	i: 13(except)
	o: 56(t), 72(f)

nname: 19
n 19(None)[mute = self._mixers[ctrl].getmute()[0]
]:
	i: 13(try)
	o: 74()

nname: 13
n 13(None)[ctrl = control
]:
	i: 0(t), 6()
	o: 19(try), 46(except)

nname: 6
n 6(None)[]:
	i: 0(f)
	o: 13()

nname: 0
n 0(control)[]:
	i: 
	o: 6(f), 13(t)

nname: 74
n 74(None)[return mute
]:
	i: 19()
	o: 

nname: 19
n 19(None)[try:
	mute = self._mixers[ctrl].getmute()[0]
except ALSAAudioError:
	mute = self.soft_mute_flag
]:
	i: 0(try)
	o: 74()

nname: 0
n 0(None)[if not control:
	pass
ctrl = control
]:
	i: 
	o: 19(try)

nname: 74
n 74(None)[return mute
]:
	i: 0()
	o: 

nname: 0
n 0(None)[if not control:
	pass
ctrl = control
try:
	mute = self._mixers[ctrl].getmute()[0]
except ALSAAudioError:
	mute = self.soft_mute_flag
]:
	i: 
	o: 74()

nname: 0
n 0(None)[if not control:
	pass
ctrl = control
try:
	mute = self._mixers[ctrl].getmute()[0]
except ALSAAudioError:
	mute = self.soft_mute_flag
return mute
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d002c>}
nname: 109
n 109(None)[]:
	i: 17(), 79(), 108()
	o: 

nname: 108
n 108(None)[]:
	i: 61&69(f)
	o: 109()

nname: 79
n 79(None)[self.set_volume(self.soft_mute_prev_vol)
self.soft_mute_flag = 0
]:
	i: 61&69(t)
	o: 109()

nname: 61&69
n 61&69(not mute and self.soft_mute_flag)[]:
	i: 0&6(f)
	o: 79(t), 108(f)

nname: 17
n 17(None)[self.soft_mute_prev_vol = self._vol_id
self.set_volume(0, dummy=True)
self.soft_mute_flag = 1
]:
	i: 0&6(t)
	o: 109()

nname: 0&6
n 0&6(mute and not self.soft_mute_flag)[]:
	i: 
	o: 17(t), 61&69(f)

nname: 0&6
n 0&6(None)[if mute and not self.soft_mute_flag:
	self.soft_mute_prev_vol = self._vol_id
	self.set_volume(0, dummy=True)
	self.soft_mute_flag = 1
else:
	if not mute and self.soft_mute_flag:
		self.set_volume(self.soft_mute_prev_vol)
		self.soft_mute_flag = 0
]:
	i: 
	o: 

self.nodes: {'0&6': <unpyclib.structure.node instance at 0xb76d0bcc>}
nname: 52
n 52(None)[]:
	i: 3(), 30(), 50(AE)
	o: 

nname: 50
n 50(None)[]:
	i: 20(f)
	o: 52(AE)

nname: 30
n 30(None)[self._soft_mute(mute)
]:
	i: 20(t)
	o: 52()

nname: 20
n 20(<dummy_ex3> EXC_MATCH ALSAAudioError)[]:
	i: 0(except)
	o: 30(t), 50(f)

nname: 3
n 3(None)[mix.setmute(mute)
]:
	i: 0(try)
	o: 52()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 20(except)

nname: 20
n 20(None)[except ALSAAudioError:
	self._soft_mute(mute)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	mix.setmute(mute)
]:
	i: 
	o: 20()

nname: 0
n 0(None)[try:
	mix.setmute(mute)
except ALSAAudioError:
	self._soft_mute(mute)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76cccac>}
nname: 91
n 91(None)[user_config['sound']['mute'] = mute
self._save_task.start(1)
]:
	i: 21(), 45(AL), 90()
	o: 

nname: 90
n 90(None)[]:
	i: 49(AF), 65()
	o: 91()

nname: 65
n 65(None)[for name, mix in self._mixers.iteritems():
secure_mute(mix, mute)
]:
	i: 49(for)
	o: 90()

nname: 49
n 49(None)[]:
	i: 45(loop)
	o: 65(for), 90(AF)

nname: 45
n 45(None)[]:
	i: 0(f)
	o: 49(loop), 91(AL)

nname: 21
n 21(None)[secure_mute(self._mixers[control], mute)
]:
	i: 0(t)
	o: 91()

nname: 0
n 0(control)[def secure_mute(mix, mute):
	try:
		mix.setmute(mute)
	except ALSAAudioError:
		self._soft_mute(mute)

]:
	i: 
	o: 21(t), 45(f)

nname: 91
n 91(None)[user_config['sound']['mute'] = mute
self._save_task.start(1)
]:
	i: 21(), 65()
	o: 

nname: 65
n 65(None)[for name, mix in self._mixers.iteritems():
	secure_mute(mix, mute)
]:
	i: 45(for)
	o: 91()

nname: 45
n 45(None)[]:
	i: 0(f)
	o: 65(for)

nname: 21
n 21(None)[secure_mute(self._mixers[control], mute)
]:
	i: 0(t)
	o: 91()

nname: 0
n 0(control)[def secure_mute(mix, mute):
	try:
		mix.setmute(mute)
	except ALSAAudioError:
		self._soft_mute(mute)

]:
	i: 
	o: 21(t), 45(f)

nname: 91
n 91(None)[user_config['sound']['mute'] = mute
self._save_task.start(1)
]:
	i: 21(), 45()
	o: 

nname: 45
n 45(None)[for name, mix in self._mixers.iteritems():
	secure_mute(mix, mute)
]:
	i: 0(f)
	o: 91()

nname: 21
n 21(None)[secure_mute(self._mixers[control], mute)
]:
	i: 0(t)
	o: 91()

nname: 0
n 0(control)[def secure_mute(mix, mute):
	try:
		mix.setmute(mute)
	except ALSAAudioError:
		self._soft_mute(mute)

]:
	i: 
	o: 21(t), 45(f)

nname: 0
n 0(None)[def secure_mute(mix, mute):
	try:
		mix.setmute(mute)
	except ALSAAudioError:
		self._soft_mute(mute)

if control:
	secure_mute(self._mixers[control], mute)
else:
	for name, mix in self._mixers.iteritems():
		secure_mute(mix, mute)
user_config['sound']['mute'] = mute
self._save_task.start(1)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0c6c>}
nname: 96
n 96(None)[]:
	i: 3(), 62(), 94(AE)
	o: 

nname: 94
n 94(None)[]:
	i: 52(f)
	o: 96(AE)

nname: 62
n 62(None)[#, e
log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
return False
]:
	i: 52(t)
	o: 96()

nname: 52
n 52(<dummy_ex3> EXC_MATCH ALSAAudioError)[]:
	i: 0(except)
	o: 62(t), 94(f)

nname: 3
n 3(None)[mix = Mixer('HDMI')
mix.setmute(mute)
log.debug('Set HDMI sound control to %s', mute)
return True
]:
	i: 0(try)
	o: 96()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 52(except)

nname: 52
n 52(None)[except ALSAAudioError, e:
	log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
	return False
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	mix = Mixer('HDMI')
	mix.setmute(mute)
	log.debug('Set HDMI sound control to %s', mute)
	return True
]:
	i: 
	o: 52()

nname: 0
n 0(None)[try:
	mix = Mixer('HDMI')
	mix.setmute(mute)
	log.debug('Set HDMI sound control to %s', mute)
	return True
except ALSAAudioError, e:
	log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
	return False
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0e4c>}
nname: 32
n 32(None)[new_mute = 1
log.debug('Volume Mute -> %s', new_mute)
self.set_mute(new_mute, control)
self._notification()
]:
	i: 21(), 28()
	o: 

nname: 28
n 28(None)[]:
	i: 0(f)
	o: 32()

nname: 21
n 21(None)[]:
	i: 0(t)
	o: 32()

nname: 0
n 0(current)[current = self.get_mute(control)
]:
	i: 
	o: 21(t), 28(f)

nname: 0
n 0(None)[current = self.get_mute(control)
if current:
	pass
new_mute = 1
log.debug('Volume Mute -> %s', new_mute)
self.set_mute(new_mute, control)
self._notification()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0e2c>}
nname: 0
n 0(None)[new_vol_id = self._vol_id + 1
log.debug('Volume UP -> %s', new_vol_id)
self.set_mute(0, control)
self.set_volume(new_vol_id, control)
self._notification()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d094c>}
nname: 0
n 0(None)[new_vol_id = self._vol_id - 1
log.debug('Volume DOWN -> %s', new_vol_id)
self.set_mute(0, control)
self.set_volume(new_vol_id, control)
self._notification()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76d0bac>}
nname: 6
n 6(None)[__metaclass__ = MetaSingleton
def __init__(self, control='Primary', id=0, card='hw:4'):
	self._mixers = dict()
	self._limiters = dict()
	self._def_control = control
	self._def_id = id
	self._def_card = card
	if architecture == 'pc':
		self._mixers['Fake'] = FakeMixer()
		self._def_control = 'Fake'
	else:
		self.add_control(control)
	events_watch(self.handle)
	self.window = SoundLevelWindow(_('Sound level'))
	self.mute_window = MuteWindow(_('Mute'))
	self._hide_task = Task(self.window.hide)
	self._hide_mute_task = Task(self.mute_window.hide)
	self._save_task = Task(user_config.save)
	self.soft_mute_flag = 0
	self.soft_mute_prev_vol = 0
	self._fill_limiters()
	self._gain = False
	self._vol_id = user_config['sound']['volume']
	self.set_volume(self._vol_id)
	self.set_mute(user_config['sound']['mute'])
	self.set_hdmi_mute(user_config['connections']['hdmi_sound'])
	self._notification()

def handle(self, event):
	if event.name in ('VOLUME_DOWN', 'VOLUME_UP', 'MUTE'):
		getattr(self, event.name.lower())()

def _switch_gain_override(self):
	try:
		gain = Mixer('Gain Override')
		gain.setmute(0)
	except ALSAAudioError:
		gain = Mixer('Gain Override', self._def_id, self._def_card)
		gain.setmute(0)

def _fill_limiters(self):
	for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
		try:
			self._limiters[limiter] = Mixer(limiter)
			continue
		except ALSAAudioError:
			self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
			continue

def _notification(self):
	self.window.mute = self.get_mute()
	self.window.progress = volume_progress_dict[self._vol_id]['progress']
	if not self._hide_task.running:
		self.window.show()
	self._hide_task.start(HMI_BASE['volumewindow_duration'])
	if self.get_mute():
		self.mute_window.show()
	else:
		self._hide_mute_task.start(0)

def add_control(self, control):
	try:
		self._mixers[control] = Mixer(control)
	except ALSAAudioError:
		self._mixers[control] = Mixer(control, self._def_id, self._def_card)

def switch_limiters(self, val):
	log.debug('switch limiters to: %s', val)
	for name, mix in self._limiters.iteritems():
		mix.setmute(val)

def get_volume(self, control=None):
	if not control:
		pass
	ctrl = control
	try:
		volume = self._mixers[ctrl].getvolume()[0]
		if self.soft_mute_flag:
			volume = self.soft_mute_prev_vol

def set_volume(self, vol_id, dummy=False, control=None):
	vol_id = min(vol_id, len(volume_progress_dict) - 1)
	vol_id = max(vol_id, 0)
	volume = volume_progress_dict[vol_id]['vol']
	log.debug('vol_id:%s volume=%s', vol_id, volume)
	if volume >= 12.5:
		self._gain = True
		log.debug('gain ON')
		self.switch_limiters(0)
	else:
		self._gain = False
		log.debug('gain OFF')
		self.switch_limiters(1)
	if control:
		self._mixers[control].setvolume(volume)
	else:
		for name, mix in self._mixers.iteritems():
			mix.setvolume(volume)
	if not dummy:
		self._vol_id = vol_id
		user_config['sound']['volume'] = self._vol_id
		self._save_task.start(1)

def get_mute(self, control=None):
	if not control:
		pass
	ctrl = control
	try:
		mute = self._mixers[ctrl].getmute()[0]
	except ALSAAudioError:
		mute = self.soft_mute_flag
	return mute

def _soft_mute(self, mute):
	if mute and not self.soft_mute_flag:
		self.soft_mute_prev_vol = self._vol_id
		self.set_volume(0, dummy=True)
		self.soft_mute_flag = 1
	else:
		if not mute and self.soft_mute_flag:
			self.set_volume(self.soft_mute_prev_vol)
			self.soft_mute_flag = 0

def set_mute(self, mute, control=None):
	def secure_mute(mix, mute):
		try:
			mix.setmute(mute)
		except ALSAAudioError:
			self._soft_mute(mute)

	if control:
		secure_mute(self._mixers[control], mute)
	else:
		for name, mix in self._mixers.iteritems():
			secure_mute(mix, mute)
	user_config['sound']['mute'] = mute
	self._save_task.start(1)

def set_hdmi_mute(self, mute):
	try:
		mix = Mixer('HDMI')
		mix.setmute(mute)
		log.debug('Set HDMI sound control to %s', mute)
		return True
	except ALSAAudioError, e:
		log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
		return False

def mute(self, control=None):
	current = self.get_mute(control)
	if current:
		pass
	new_mute = 1
	log.debug('Volume Mute -> %s', new_mute)
	self.set_mute(new_mute, control)
	self._notification()

toggle_mute = mute
def volume_up(self, val=3, control=None):
	new_vol_id = self._vol_id + 1
	log.debug('Volume UP -> %s', new_vol_id)
	self.set_mute(0, control)
	self.set_volume(new_vol_id, control)
	self._notification()

def volume_down(self, val=3, control=None):
	new_vol_id = self._vol_id - 1
	log.debug('Volume DOWN -> %s', new_vol_id)
	self.set_mute(0, control)
	self.set_volume(new_vol_id, control)
	self._notification()

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb773deec>}
nname: 472
n 472(None)[class Mix(object):
	__metaclass__ = MetaSingleton
	def __init__(self, control='Primary', id=0, card='hw:4'):
		self._mixers = dict()
		self._limiters = dict()
		self._def_control = control
		self._def_id = id
		self._def_card = card
		if architecture == 'pc':
			self._mixers['Fake'] = FakeMixer()
			self._def_control = 'Fake'
		else:
			self.add_control(control)
		events_watch(self.handle)
		self.window = SoundLevelWindow(_('Sound level'))
		self.mute_window = MuteWindow(_('Mute'))
		self._hide_task = Task(self.window.hide)
		self._hide_mute_task = Task(self.mute_window.hide)
		self._save_task = Task(user_config.save)
		self.soft_mute_flag = 0
		self.soft_mute_prev_vol = 0
		self._fill_limiters()
		self._gain = False
		self._vol_id = user_config['sound']['volume']
		self.set_volume(self._vol_id)
		self.set_mute(user_config['sound']['mute'])
		self.set_hdmi_mute(user_config['connections']['hdmi_sound'])
		self._notification()

	def handle(self, event):
		if event.name in ('VOLUME_DOWN', 'VOLUME_UP', 'MUTE'):
			getattr(self, event.name.lower())()

	def _switch_gain_override(self):
		try:
			gain = Mixer('Gain Override')
			gain.setmute(0)
		except ALSAAudioError:
			gain = Mixer('Gain Override', self._def_id, self._def_card)
			gain.setmute(0)

	def _fill_limiters(self):
		for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
			try:
				self._limiters[limiter] = Mixer(limiter)
				continue
			except ALSAAudioError:
				self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
				continue

	def _notification(self):
		self.window.mute = self.get_mute()
		self.window.progress = volume_progress_dict[self._vol_id]['progress']
		if not self._hide_task.running:
			self.window.show()
		self._hide_task.start(HMI_BASE['volumewindow_duration'])
		if self.get_mute():
			self.mute_window.show()
		else:
			self._hide_mute_task.start(0)

	def add_control(self, control):
		try:
			self._mixers[control] = Mixer(control)
		except ALSAAudioError:
			self._mixers[control] = Mixer(control, self._def_id, self._def_card)

	def switch_limiters(self, val):
		log.debug('switch limiters to: %s', val)
		for name, mix in self._limiters.iteritems():
			mix.setmute(val)

	def get_volume(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			volume = self._mixers[ctrl].getvolume()[0]
			if self.soft_mute_flag:
				volume = self.soft_mute_prev_vol

	def set_volume(self, vol_id, dummy=False, control=None):
		vol_id = min(vol_id, len(volume_progress_dict) - 1)
		vol_id = max(vol_id, 0)
		volume = volume_progress_dict[vol_id]['vol']
		log.debug('vol_id:%s volume=%s', vol_id, volume)
		if volume >= 12.5:
			self._gain = True
			log.debug('gain ON')
			self.switch_limiters(0)
		else:
			self._gain = False
			log.debug('gain OFF')
			self.switch_limiters(1)
		if control:
			self._mixers[control].setvolume(volume)
		else:
			for name, mix in self._mixers.iteritems():
				mix.setvolume(volume)
		if not dummy:
			self._vol_id = vol_id
			user_config['sound']['volume'] = self._vol_id
			self._save_task.start(1)

	def get_mute(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			mute = self._mixers[ctrl].getmute()[0]
		except ALSAAudioError:
			mute = self.soft_mute_flag
		return mute

	def _soft_mute(self, mute):
		if mute and not self.soft_mute_flag:
			self.soft_mute_prev_vol = self._vol_id
			self.set_volume(0, dummy=True)
			self.soft_mute_flag = 1
		else:
			if not mute and self.soft_mute_flag:
				self.set_volume(self.soft_mute_prev_vol)
				self.soft_mute_flag = 0

	def set_mute(self, mute, control=None):
		def secure_mute(mix, mute):
			try:
				mix.setmute(mute)
			except ALSAAudioError:
				self._soft_mute(mute)

		if control:
			secure_mute(self._mixers[control], mute)
		else:
			for name, mix in self._mixers.iteritems():
				secure_mute(mix, mute)
		user_config['sound']['mute'] = mute
		self._save_task.start(1)

	def set_hdmi_mute(self, mute):
		try:
			mix = Mixer('HDMI')
			mix.setmute(mute)
			log.debug('Set HDMI sound control to %s', mute)
			return True
		except ALSAAudioError, e:
			log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
			return False

	def mute(self, control=None):
		current = self.get_mute(control)
		if current:
			pass
		new_mute = 1
		log.debug('Volume Mute -> %s', new_mute)
		self.set_mute(new_mute, control)
		self._notification()

	toggle_mute = mute
	def volume_up(self, val=3, control=None):
		new_vol_id = self._vol_id + 1
		log.debug('Volume UP -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()

	def volume_down(self, val=3, control=None):
		new_vol_id = self._vol_id - 1
		log.debug('Volume DOWN -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()



]:
	i: 414(), 440(), 471(AE)
	o: 

nname: 440
n 440(None)[log.error('ALSA not found ! using FakeMixer instead')
Mixer = FakeMixer
ALSAAudioError = Exception
]:
	i: 0(except)
	o: 472()

nname: 414
n 414(None)[from alsaaudio import Mixer, ALSAAudioError
]:
	i: 0(try)
	o: 472()

nname: 0
n 0(None)[from __future__ import absolute_import
from peewee.misc_utils import MetaSingleton
from pygui.window import SoundLevelWindow
from pygui.window import MuteWindow
from peewee.notifier import Task, events_watch
from peewee.debug import GET_LOGGER
from pygui.config import HMI_BASE, user_config
from pygui.config import architecture
log = GET_LOGGER(__name__)
volume_progress_dict = ({'vol': 0, 'progress': 0}, {'vol': 1, 'progress': 10}, {'vol': 2, 'progress': 20}, {'vol': 3, 'progress': 30}, {'vol': 4, 'progress': 40}, {'vol': 5, 'progress': 50}, {'vol': 6, 'progress': 60}, {'vol': 7, 'progress': 70}, {'vol': 8, 'progress': 80}, {'vol': 10, 'progress': 90}, {'vol': 12, 'progress': 100})
class FakeMixer(object):
	__doc__ = ' only used on x86 '
	def __init__(self, *args, **args):
		self._vol = 50
		self._mute = 0

	def getvolume(self):
		return (self._vol, self._vol)

	def setvolume(self, val):
		self._vol = val

	def getmute(self):
		return (self._mute, self._mute)

	def setmute(self, val):
		self._mute = val



]:
	i: 
	o: 414(try), 440(except)

nname: 440
n 440(None)[except:
	log.error('ALSA not found ! using FakeMixer instead')
	Mixer = FakeMixer
	ALSAAudioError = Exception
class Mix(object):
	__metaclass__ = MetaSingleton
	def __init__(self, control='Primary', id=0, card='hw:4'):
		self._mixers = dict()
		self._limiters = dict()
		self._def_control = control
		self._def_id = id
		self._def_card = card
		if architecture == 'pc':
			self._mixers['Fake'] = FakeMixer()
			self._def_control = 'Fake'
		else:
			self.add_control(control)
		events_watch(self.handle)
		self.window = SoundLevelWindow(_('Sound level'))
		self.mute_window = MuteWindow(_('Mute'))
		self._hide_task = Task(self.window.hide)
		self._hide_mute_task = Task(self.mute_window.hide)
		self._save_task = Task(user_config.save)
		self.soft_mute_flag = 0
		self.soft_mute_prev_vol = 0
		self._fill_limiters()
		self._gain = False
		self._vol_id = user_config['sound']['volume']
		self.set_volume(self._vol_id)
		self.set_mute(user_config['sound']['mute'])
		self.set_hdmi_mute(user_config['connections']['hdmi_sound'])
		self._notification()

	def handle(self, event):
		if event.name in ('VOLUME_DOWN', 'VOLUME_UP', 'MUTE'):
			getattr(self, event.name.lower())()

	def _switch_gain_override(self):
		try:
			gain = Mixer('Gain Override')
			gain.setmute(0)
		except ALSAAudioError:
			gain = Mixer('Gain Override', self._def_id, self._def_card)
			gain.setmute(0)

	def _fill_limiters(self):
		for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
			try:
				self._limiters[limiter] = Mixer(limiter)
				continue
			except ALSAAudioError:
				self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
				continue

	def _notification(self):
		self.window.mute = self.get_mute()
		self.window.progress = volume_progress_dict[self._vol_id]['progress']
		if not self._hide_task.running:
			self.window.show()
		self._hide_task.start(HMI_BASE['volumewindow_duration'])
		if self.get_mute():
			self.mute_window.show()
		else:
			self._hide_mute_task.start(0)

	def add_control(self, control):
		try:
			self._mixers[control] = Mixer(control)
		except ALSAAudioError:
			self._mixers[control] = Mixer(control, self._def_id, self._def_card)

	def switch_limiters(self, val):
		log.debug('switch limiters to: %s', val)
		for name, mix in self._limiters.iteritems():
			mix.setmute(val)

	def get_volume(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			volume = self._mixers[ctrl].getvolume()[0]
			if self.soft_mute_flag:
				volume = self.soft_mute_prev_vol

	def set_volume(self, vol_id, dummy=False, control=None):
		vol_id = min(vol_id, len(volume_progress_dict) - 1)
		vol_id = max(vol_id, 0)
		volume = volume_progress_dict[vol_id]['vol']
		log.debug('vol_id:%s volume=%s', vol_id, volume)
		if volume >= 12.5:
			self._gain = True
			log.debug('gain ON')
			self.switch_limiters(0)
		else:
			self._gain = False
			log.debug('gain OFF')
			self.switch_limiters(1)
		if control:
			self._mixers[control].setvolume(volume)
		else:
			for name, mix in self._mixers.iteritems():
				mix.setvolume(volume)
		if not dummy:
			self._vol_id = vol_id
			user_config['sound']['volume'] = self._vol_id
			self._save_task.start(1)

	def get_mute(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			mute = self._mixers[ctrl].getmute()[0]
		except ALSAAudioError:
			mute = self.soft_mute_flag
		return mute

	def _soft_mute(self, mute):
		if mute and not self.soft_mute_flag:
			self.soft_mute_prev_vol = self._vol_id
			self.set_volume(0, dummy=True)
			self.soft_mute_flag = 1
		else:
			if not mute and self.soft_mute_flag:
				self.set_volume(self.soft_mute_prev_vol)
				self.soft_mute_flag = 0

	def set_mute(self, mute, control=None):
		def secure_mute(mix, mute):
			try:
				mix.setmute(mute)
			except ALSAAudioError:
				self._soft_mute(mute)

		if control:
			secure_mute(self._mixers[control], mute)
		else:
			for name, mix in self._mixers.iteritems():
				secure_mute(mix, mute)
		user_config['sound']['mute'] = mute
		self._save_task.start(1)

	def set_hdmi_mute(self, mute):
		try:
			mix = Mixer('HDMI')
			mix.setmute(mute)
			log.debug('Set HDMI sound control to %s', mute)
			return True
		except ALSAAudioError, e:
			log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
			return False

	def mute(self, control=None):
		current = self.get_mute(control)
		if current:
			pass
		new_mute = 1
		log.debug('Volume Mute -> %s', new_mute)
		self.set_mute(new_mute, control)
		self._notification()

	toggle_mute = mute
	def volume_up(self, val=3, control=None):
		new_vol_id = self._vol_id + 1
		log.debug('Volume UP -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()

	def volume_down(self, val=3, control=None):
		new_vol_id = self._vol_id - 1
		log.debug('Volume DOWN -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()



]:
	i: 0()
	o: 

nname: 0
n 0(None)[from __future__ import absolute_import
from peewee.misc_utils import MetaSingleton
from pygui.window import SoundLevelWindow
from pygui.window import MuteWindow
from peewee.notifier import Task, events_watch
from peewee.debug import GET_LOGGER
from pygui.config import HMI_BASE, user_config
from pygui.config import architecture
log = GET_LOGGER(__name__)
volume_progress_dict = ({'vol': 0, 'progress': 0}, {'vol': 1, 'progress': 10}, {'vol': 2, 'progress': 20}, {'vol': 3, 'progress': 30}, {'vol': 4, 'progress': 40}, {'vol': 5, 'progress': 50}, {'vol': 6, 'progress': 60}, {'vol': 7, 'progress': 70}, {'vol': 8, 'progress': 80}, {'vol': 10, 'progress': 90}, {'vol': 12, 'progress': 100})
class FakeMixer(object):
	__doc__ = ' only used on x86 '
	def __init__(self, *args, **args):
		self._vol = 50
		self._mute = 0

	def getvolume(self):
		return (self._vol, self._vol)

	def setvolume(self, val):
		self._vol = val

	def getmute(self):
		return (self._mute, self._mute)

	def setmute(self, val):
		self._mute = val



try:
	from alsaaudio import Mixer, ALSAAudioError
]:
	i: 
	o: 440()

nname: 0
n 0(None)[from __future__ import absolute_import
from peewee.misc_utils import MetaSingleton
from pygui.window import SoundLevelWindow
from pygui.window import MuteWindow
from peewee.notifier import Task, events_watch
from peewee.debug import GET_LOGGER
from pygui.config import HMI_BASE, user_config
from pygui.config import architecture
log = GET_LOGGER(__name__)
volume_progress_dict = ({'vol': 0, 'progress': 0}, {'vol': 1, 'progress': 10}, {'vol': 2, 'progress': 20}, {'vol': 3, 'progress': 30}, {'vol': 4, 'progress': 40}, {'vol': 5, 'progress': 50}, {'vol': 6, 'progress': 60}, {'vol': 7, 'progress': 70}, {'vol': 8, 'progress': 80}, {'vol': 10, 'progress': 90}, {'vol': 12, 'progress': 100})
class FakeMixer(object):
	__doc__ = ' only used on x86 '
	def __init__(self, *args, **args):
		self._vol = 50
		self._mute = 0

	def getvolume(self):
		return (self._vol, self._vol)

	def setvolume(self, val):
		self._vol = val

	def getmute(self):
		return (self._mute, self._mute)

	def setmute(self, val):
		self._mute = val



try:
	from alsaaudio import Mixer, ALSAAudioError
except:
	log.error('ALSA not found ! using FakeMixer instead')
	Mixer = FakeMixer
	ALSAAudioError = Exception
class Mix(object):
	__metaclass__ = MetaSingleton
	def __init__(self, control='Primary', id=0, card='hw:4'):
		self._mixers = dict()
		self._limiters = dict()
		self._def_control = control
		self._def_id = id
		self._def_card = card
		if architecture == 'pc':
			self._mixers['Fake'] = FakeMixer()
			self._def_control = 'Fake'
		else:
			self.add_control(control)
		events_watch(self.handle)
		self.window = SoundLevelWindow(_('Sound level'))
		self.mute_window = MuteWindow(_('Mute'))
		self._hide_task = Task(self.window.hide)
		self._hide_mute_task = Task(self.mute_window.hide)
		self._save_task = Task(user_config.save)
		self.soft_mute_flag = 0
		self.soft_mute_prev_vol = 0
		self._fill_limiters()
		self._gain = False
		self._vol_id = user_config['sound']['volume']
		self.set_volume(self._vol_id)
		self.set_mute(user_config['sound']['mute'])
		self.set_hdmi_mute(user_config['connections']['hdmi_sound'])
		self._notification()

	def handle(self, event):
		if event.name in ('VOLUME_DOWN', 'VOLUME_UP', 'MUTE'):
			getattr(self, event.name.lower())()

	def _switch_gain_override(self):
		try:
			gain = Mixer('Gain Override')
			gain.setmute(0)
		except ALSAAudioError:
			gain = Mixer('Gain Override', self._def_id, self._def_card)
			gain.setmute(0)

	def _fill_limiters(self):
		for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
			try:
				self._limiters[limiter] = Mixer(limiter)
				continue
			except ALSAAudioError:
				self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
				continue

	def _notification(self):
		self.window.mute = self.get_mute()
		self.window.progress = volume_progress_dict[self._vol_id]['progress']
		if not self._hide_task.running:
			self.window.show()
		self._hide_task.start(HMI_BASE['volumewindow_duration'])
		if self.get_mute():
			self.mute_window.show()
		else:
			self._hide_mute_task.start(0)

	def add_control(self, control):
		try:
			self._mixers[control] = Mixer(control)
		except ALSAAudioError:
			self._mixers[control] = Mixer(control, self._def_id, self._def_card)

	def switch_limiters(self, val):
		log.debug('switch limiters to: %s', val)
		for name, mix in self._limiters.iteritems():
			mix.setmute(val)

	def get_volume(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			volume = self._mixers[ctrl].getvolume()[0]
			if self.soft_mute_flag:
				volume = self.soft_mute_prev_vol

	def set_volume(self, vol_id, dummy=False, control=None):
		vol_id = min(vol_id, len(volume_progress_dict) - 1)
		vol_id = max(vol_id, 0)
		volume = volume_progress_dict[vol_id]['vol']
		log.debug('vol_id:%s volume=%s', vol_id, volume)
		if volume >= 12.5:
			self._gain = True
			log.debug('gain ON')
			self.switch_limiters(0)
		else:
			self._gain = False
			log.debug('gain OFF')
			self.switch_limiters(1)
		if control:
			self._mixers[control].setvolume(volume)
		else:
			for name, mix in self._mixers.iteritems():
				mix.setvolume(volume)
		if not dummy:
			self._vol_id = vol_id
			user_config['sound']['volume'] = self._vol_id
			self._save_task.start(1)

	def get_mute(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			mute = self._mixers[ctrl].getmute()[0]
		except ALSAAudioError:
			mute = self.soft_mute_flag
		return mute

	def _soft_mute(self, mute):
		if mute and not self.soft_mute_flag:
			self.soft_mute_prev_vol = self._vol_id
			self.set_volume(0, dummy=True)
			self.soft_mute_flag = 1
		else:
			if not mute and self.soft_mute_flag:
				self.set_volume(self.soft_mute_prev_vol)
				self.soft_mute_flag = 0

	def set_mute(self, mute, control=None):
		def secure_mute(mix, mute):
			try:
				mix.setmute(mute)
			except ALSAAudioError:
				self._soft_mute(mute)

		if control:
			secure_mute(self._mixers[control], mute)
		else:
			for name, mix in self._mixers.iteritems():
				secure_mute(mix, mute)
		user_config['sound']['mute'] = mute
		self._save_task.start(1)

	def set_hdmi_mute(self, mute):
		try:
			mix = Mixer('HDMI')
			mix.setmute(mute)
			log.debug('Set HDMI sound control to %s', mute)
			return True
		except ALSAAudioError, e:
			log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
			return False

	def mute(self, control=None):
		current = self.get_mute(control)
		if current:
			pass
		new_mute = 1
		log.debug('Volume Mute -> %s', new_mute)
		self.set_mute(new_mute, control)
		self._notification()

	toggle_mute = mute
	def volume_up(self, val=3, control=None):
		new_vol_id = self._vol_id + 1
		log.debug('Volume UP -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()

	def volume_down(self, val=3, control=None):
		new_vol_id = self._vol_id - 1
		log.debug('Volume DOWN -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb773dd8c>}
from __future__ import absolute_import
from peewee.misc_utils import MetaSingleton
from pygui.window import SoundLevelWindow
from pygui.window import MuteWindow
from peewee.notifier import Task, events_watch
from peewee.debug import GET_LOGGER
from pygui.config import HMI_BASE, user_config
from pygui.config import architecture
log = GET_LOGGER(__name__)
volume_progress_dict = ({'vol': 0, 'progress': 0}, {'vol': 1, 'progress': 10}, {'vol': 2, 'progress': 20}, {'vol': 3, 'progress': 30}, {'vol': 4, 'progress': 40}, {'vol': 5, 'progress': 50}, {'vol': 6, 'progress': 60}, {'vol': 7, 'progress': 70}, {'vol': 8, 'progress': 80}, {'vol': 10, 'progress': 90}, {'vol': 12, 'progress': 100})
class FakeMixer(object):
	__doc__ = ' only used on x86 '
	def __init__(self, *args, **args):
		self._vol = 50
		self._mute = 0

	def getvolume(self):
		return (self._vol, self._vol)

	def setvolume(self, val):
		self._vol = val

	def getmute(self):
		return (self._mute, self._mute)

	def setmute(self, val):
		self._mute = val



try:
	from alsaaudio import Mixer, ALSAAudioError
except:
	log.error('ALSA not found ! using FakeMixer instead')
	Mixer = FakeMixer
	ALSAAudioError = Exception
class Mix(object):
	__metaclass__ = MetaSingleton
	def __init__(self, control='Primary', id=0, card='hw:4'):
		self._mixers = dict()
		self._limiters = dict()
		self._def_control = control
		self._def_id = id
		self._def_card = card
		if architecture == 'pc':
			self._mixers['Fake'] = FakeMixer()
			self._def_control = 'Fake'
		else:
			self.add_control(control)
		events_watch(self.handle)
		self.window = SoundLevelWindow(_('Sound level'))
		self.mute_window = MuteWindow(_('Mute'))
		self._hide_task = Task(self.window.hide)
		self._hide_mute_task = Task(self.mute_window.hide)
		self._save_task = Task(user_config.save)
		self.soft_mute_flag = 0
		self.soft_mute_prev_vol = 0
		self._fill_limiters()
		self._gain = False
		self._vol_id = user_config['sound']['volume']
		self.set_volume(self._vol_id)
		self.set_mute(user_config['sound']['mute'])
		self.set_hdmi_mute(user_config['connections']['hdmi_sound'])
		self._notification()

	def handle(self, event):
		if event.name in ('VOLUME_DOWN', 'VOLUME_UP', 'MUTE'):
			getattr(self, event.name.lower())()

	def _switch_gain_override(self):
		try:
			gain = Mixer('Gain Override')
			gain.setmute(0)
		except ALSAAudioError:
			gain = Mixer('Gain Override', self._def_id, self._def_card)
			gain.setmute(0)

	def _fill_limiters(self):
		for limiter in ('Analog Limiter', 'HDMI Limiter', 'SPDIF Limiter'):
			try:
				self._limiters[limiter] = Mixer(limiter)
				continue
			except ALSAAudioError:
				self._limiters[limiter] = Mixer(limiter, self._def_id, self._def_card)
				continue

	def _notification(self):
		self.window.mute = self.get_mute()
		self.window.progress = volume_progress_dict[self._vol_id]['progress']
		if not self._hide_task.running:
			self.window.show()
		self._hide_task.start(HMI_BASE['volumewindow_duration'])
		if self.get_mute():
			self.mute_window.show()
		else:
			self._hide_mute_task.start(0)

	def add_control(self, control):
		try:
			self._mixers[control] = Mixer(control)
		except ALSAAudioError:
			self._mixers[control] = Mixer(control, self._def_id, self._def_card)

	def switch_limiters(self, val):
		log.debug('switch limiters to: %s', val)
		for name, mix in self._limiters.iteritems():
			mix.setmute(val)

	def get_volume(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			volume = self._mixers[ctrl].getvolume()[0]
			if self.soft_mute_flag:
				volume = self.soft_mute_prev_vol

	def set_volume(self, vol_id, dummy=False, control=None):
		vol_id = min(vol_id, len(volume_progress_dict) - 1)
		vol_id = max(vol_id, 0)
		volume = volume_progress_dict[vol_id]['vol']
		log.debug('vol_id:%s volume=%s', vol_id, volume)
		if volume >= 12.5:
			self._gain = True
			log.debug('gain ON')
			self.switch_limiters(0)
		else:
			self._gain = False
			log.debug('gain OFF')
			self.switch_limiters(1)
		if control:
			self._mixers[control].setvolume(volume)
		else:
			for name, mix in self._mixers.iteritems():
				mix.setvolume(volume)
		if not dummy:
			self._vol_id = vol_id
			user_config['sound']['volume'] = self._vol_id
			self._save_task.start(1)

	def get_mute(self, control=None):
		if not control:
			pass
		ctrl = control
		try:
			mute = self._mixers[ctrl].getmute()[0]
		except ALSAAudioError:
			mute = self.soft_mute_flag
		return mute

	def _soft_mute(self, mute):
		if mute and not self.soft_mute_flag:
			self.soft_mute_prev_vol = self._vol_id
			self.set_volume(0, dummy=True)
			self.soft_mute_flag = 1
		else:
			if not mute and self.soft_mute_flag:
				self.set_volume(self.soft_mute_prev_vol)
				self.soft_mute_flag = 0

	def set_mute(self, mute, control=None):
		def secure_mute(mix, mute):
			try:
				mix.setmute(mute)
			except ALSAAudioError:
				self._soft_mute(mute)

		if control:
			secure_mute(self._mixers[control], mute)
		else:
			for name, mix in self._mixers.iteritems():
				secure_mute(mix, mute)
		user_config['sound']['mute'] = mute
		self._save_task.start(1)

	def set_hdmi_mute(self, mute):
		try:
			mix = Mixer('HDMI')
			mix.setmute(mute)
			log.debug('Set HDMI sound control to %s', mute)
			return True
		except ALSAAudioError, e:
			log.error('Impossible to set HDMI sound mute to %s <%s>', mute, e)
			return False

	def mute(self, control=None):
		current = self.get_mute(control)
		if current:
			pass
		new_mute = 1
		log.debug('Volume Mute -> %s', new_mute)
		self.set_mute(new_mute, control)
		self._notification()

	toggle_mute = mute
	def volume_up(self, val=3, control=None):
		new_vol_id = self._vol_id + 1
		log.debug('Volume UP -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()

	def volume_down(self, val=3, control=None):
		new_vol_id = self._vol_id - 1
		log.debug('Volume DOWN -> %s', new_vol_id)
		self.set_mute(0, control)
		self.set_volume(new_vol_id, control)
		self._notification()



